package ssinfis.project.kontrolarozvrhu;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.ArrayList;
import java.util.List;
import org.xmlpull.v1.XmlSerializer;

import ssinfis.project.parser.Hodina;
import ssinfis.project.parser.Parser;
import android.app.ListActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.util.Xml;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MessageList extends ListActivity {

	boolean isInternetPresent = false;
	ConnectionDetector cd;
	static String ID;
	static String PASSWORD;
	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		
		setContentView(R.layout.main);
		cd = new ConnectionDetector(getApplicationContext());
		
		Thread mgsThr = new Thread(){
			public void run(){
				HttpConnection hc = new HttpConnection();
				try {
					hc.executeHttpPost(ID, PASSWORD);
				} catch (Exception e) {
					e.printStackTrace();
				}

				try {
					hc.httpGetRozvrh();
//					
////					URL website = new URL("http://bakalari.ssinfis.cz/prehled.aspx?s=6");
////				    ReadableByteChannel rbc = Channels.newChannel(website.openStream());
//				    FileOutputStream fos = new FileOutputStream("rozvrh.html");
//				    fos.getChannel().transferFrom(rbc, 0, 1 << 24);
//					
//					FileReader fis = new FileReader(new File("rozvrh.html"));
//					Parser p = new Parser(fis);
//					Hodina [][]rozvrh = p.parse();
				} catch (Exception e) {
					e.printStackTrace();
				}}
		};
		mgsThr.start();
		
		

	//	loadFeed(ParserType.DOM);
	}

}